package com.suapi.project.service.innerImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.suapi.project.common.ErrorCode;
import com.suapi.project.exception.BusinessException;
import com.suapi.project.mapper.InterfaceInfoMapper;
import com.suapi.suapicommon.model.entity.InterfaceInfo;
import com.suapi.suapicommon.service.InnerInterfaceInfoService;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class InnerInterfaceInfoImpl implements InnerInterfaceInfoService {
    @Autowired
    private InterfaceInfoMapper interfaceInfoMapper;

    @Override
    public InterfaceInfo getInterfaceInfo(String url, String method) {
        if (StringUtils.isAnyBlank(url) || StringUtils.isAnyBlank(method)){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        QueryWrapper<InterfaceInfo> interfaceInfoQueryWrapper = new QueryWrapper<>();
        interfaceInfoQueryWrapper.eq("url",url);
        interfaceInfoQueryWrapper.eq("method",method);
        return interfaceInfoMapper.selectOne(interfaceInfoQueryWrapper);
    }
}
